[Pg, Gel] Fix PgRole and GelRole .d.ts type errors (TS2559)#5403
Open
YevheniiKotyrlo wants to merge 1 commit intodrizzle-team:mainfrom
Open
[Pg, Gel] Fix PgRole and GelRole .d.ts type errors (TS2559)#5403YevheniiKotyrlo wants to merge 1 commit intodrizzle-team:mainfrom
YevheniiKotyrlo wants to merge 1 commit intodrizzle-team:mainfrom
Conversation
f9dab9a to
c1124d4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PgRoleandGelRoledeclareimplements PgRoleConfig/GelRoleConfig, but all three config properties (createDb,createRole,inherit) are marked/** @internal */. ThestripInternal: truetsconfig setting strips them from the emitted.d.tsfiles, leaving the class with no properties in common with the interface it claims to implement.This produces TS2559 when consumers use
skipLibCheck: false:Root cause
The root
tsconfig.jsoncombinesstripInternal: truewithskipLibCheck: true. The build pipeline (tsc -p tsconfig.dts.json) emits.d.tsfiles that strip@internalmembers, but never validates the output withskipLibCheck: false. This means the emitted declarations can (and do) violate TypeScript's type rules without being caught.Fix
Remove
/** @internal */fromcreateDb,createRole, andinheritin bothpg-core/roles.tsandgel-core/roles.ts.These properties:
PgRoleConfig/GelRoleConfiginterfacesdrizzle-kit(currently viaas anycast inpgSerializer.ts:700andgelSerializer.ts:686)tests/rls/pg-role.test.ts)The
_existingproperty remains@internalas it is not part of the config interface.Changes
drizzle-orm/src/pg-core/roles.ts/** @internal */from 3 propertiesdrizzle-orm/src/gel-core/roles.ts/** @internal */from 3 propertiesEmitted
.d.tsbefore vs afterBefore (broken):
After (fixed):
Validation
tsc --noEmit— zero errorseslint— zero warningsdprint check— no formatting issuestsc -p tsconfig.dts.json—.d.tsgeneration succeedsvitest run— 562/562 tests passcd type-tests && tsc) — zero errors.d.tsvalidation withskipLibCheck: false— zero role-related errorsFixes part of #5187. Related: #4299, #4818, #3617.